package com.zx.idc.backend.gui.common;


import java.io.Serializable;

public interface ResultHelper extends Serializable {
    default <T> Result<T> success(T data) {
        return build(Result.SUCCESS, null, data);
    }

    default <T> Result<T> success(Integer code, T data) {
        return build(code, null, data);
    }

    default <T> Result<T> error(String msg) {
        return build(Result.SERVER_ERROR, msg, null);
    }

    default <T> Result<T> error(Integer code, String msg) {
        return build(code, msg, null);
    }

    default <T> Result<T> build(Integer code, String msg, T data) {
        return new Result<>(code, msg, data);
    }
}
